{#
# This file is part of Zenodo.
# Copyright (C) 2015, 2016 CERN.
#
# Zenodo is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# Zenodo is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Zenodo; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307, USA.
#
# In applying this license, CERN does not
# waive the privileges and immunities granted to it by virtue of its status
# as an Intergovernmental Organization or submit itself to any jurisdiction.
-#}

{%- extends config.ACCOUNTS_COVER_TEMPLATE %}

{% from "invenio_accounts/_macros.html" import render_field %}

{% macro form_errors(form) %}
  {%- if form.errors %}
  <div class="alert alert-danger alert-dismissible text-left" role="alert">
  <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  {%- for key,err_obj in form.errors.items() recursive %}
      {%  if err_obj is mapping %}
          {{  loop(err_obj.items()) }}
      {% else %}
          {% for single_message in err_obj %}
            <p>{{ single_message }}</p>
          {% endfor %}
      {% endif %}
  {%- endfor %}
  </div>
  {%- endif %}
{% endmacro %}


{% block panel %}
{%- set form = form or register_user_form %}
<div class="col-xs-12 col-md-10 col-md-offset-1">
  {%- block signup_slogan %}
  <h1>{{_('Research. Shared! Sign up today.')}}</h1>
  {%- endblock signup_slogan %}
  <hr />
  <div class="row">
    <div class="col-sm-6 col-sm-push-6 sign-up">
      {%- block signup_form_header %}
      <div class="social-signup">
        <a href="{{url_for('invenio_oauthclient.login', remote_app='github')}}" class="btn btn-default btn-lg btn-block"><i class="fa fa-github"></i> {{_('Sign up with GitHub')}}</a>
        <a href="{{url_for('invenio_oauthclient.login', remote_app='orcid')}}" class="btn btn-default btn-lg btn-block"><img src="{{ url_for('static', filename='img/orcid.svg')}}" height="18px"> {{_('Sign up with ORCID')}}</a>
        <h3 align="center">— OR —</h3>
      </div>
      {% endblock %}
      <form action="{%- block signup_form_endpoint %}{{ url_for_security('register') }}{% endblock %}" method="POST" name="register_user_form">
      {{form_errors(form)}}
      {{ form.csrf_token()}}
      {{ render_field(form.email, autofocus=True, errormsg=False) }}
      {{ render_field(form.profile.username, errormsg=False) }}
      {%- if form.password %}
        {{ render_field(form.password, errormsg=False) }}
      {%- endif %}
      {%- if form.password_confirm %}
        {{ render_field(form.password_confirm, icon="fa fa-lock", errormsg=False) }}
      {%- endif %}
      {%- if form.recaptcha %}
        <div class="form-group form-group-lg"><div align="center">{{ form.recaptcha() }}</div></div>
      {%- endif %}
      <button type="submit" class="btn btn-warning btn-lg btn-block"><i class="fa fa-edit"></i> {% block signup_button_text %}{{_('Sign Up')}}{% endblock %}</button>
      </form>
      {%- block signup_form_footer %}
      <p align="center">
        {{_('Already have an account?')}} <a href="{{url_for_security('login')}}">{{_('Log In')}}</a>
      </p>
      <p align="center">
        <small><a href="https://about.zenodo.org/privacy-policy/">{{_('Privacy notice')}}</a></small>
      {%- endblock %}
      </p>
    </div>
    <div class="col-sm-6 col-sm-pull-6 sign-up sign-up-benefits">
      {%- block signup_benefits %}
      <h4>{{_('Citeable. Discoverable.')}}</h4>
      <p>{{_('Uploads get a Digital Object Identifier (DOI) to make them easily and uniquely citeable.')}}</p>
      <h4>{{_('Communities')}}</h4>
      <p>{{_('Accept or reject uploads to your own community (e.g workshops, EU projects, institutions or entire disciplines).')}}</p>
      {%- endblock signup_benefits %}
      <h4>{{_('Trusted Research Data Management')}}</h4>
      <p>{{_('Built on top of CERN\'s expertise in managing 100s of petabytes of research data from the Large Hadron Collider.')}}</p>
    </div>
  </div>
</div>
{% endblock panel %}

{% block page_footer %}
<footer>
<div>
  <ul class="list-inline">
    <li><a href="https://www.openaire.eu"><img src="{{ url_for('static', filename='img/openaire.png') }}" width="80"></a></li>
    <li><a href="https://home.cern"><img src="{{ url_for('static', filename='img/cern.png') }}"></a></li>
    <li><a href="https://ec.europa.eu/programmes/horizon2020/"><img src="{{ url_for('static', filename='img/eu.png') }}"></a></li>
  </ul>
</div>
</footer>
{% endblock page_footer %}
